package com.ibeeking.found.cms.api.feign.fallback;

import com.ibeeking.found.cms.api.common.dto.PageBaseInfoDTO;
import com.ibeeking.found.cms.api.common.query.PageBaseInfoQuery;
import com.ibeeking.found.cms.api.feign.CmsFeignBClient;
import com.ibeeking.nematos.utils.data.Collections3;
import com.ibeeking.nematos.utils.result.ResponseCodeEnum;
import com.ibeeking.nematos.utils.result.ResponseResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;


/**
 * 降级工场
 *
 * @Author ibeeking
 * @date 2019/1/18
 */
@Component
public class CmsFeignBFallbackFactory implements FallbackFactory<CmsFeignBClient> {
    @Override
    public CmsFeignBClient create(Throwable throwable) {
        return new CmsFeignBClient() {
            @Override
            public ResponseResult<List<PageBaseInfoDTO>> pageBaseInfoList(List<PageBaseInfoQuery> query) {
                return ResponseResult.fail(ResponseCodeEnum.SYSTEM_ERROR.getCode(), "进入降级工厂，页面信息查询失败!", Collections3.emptyList());
            }
        };
    }
}
